<template>
  <div class="app-container" :class="{ iphonex: $isIphoneX }">
    <div class="layout-content">
      <keep-alive v-if="$route.meta.keepAlive">
        <router-view></router-view>
      </keep-alive>
      <router-view v-else></router-view>
    </div>
    <div class="layout-footer">
      <TabBar :data="tabbars" :defaultActive="active" @change="handleChange" />
    </div>
  </div>
</template>

<script>
import TabBar from '@/components/TabBar'
export default {
  name: 'AppLayout',
  data() {
    return {
      active: 0,
      tabbars: [
        {
          title: '关键指标',
          to: {
            name: 'Home'
          },
          icon: 'guanjianzhibiao',
          iconActive: 'quota-active'
        },
        {
          title: '绩效考核',
          to: {
            name: 'Analysis'
          },
          icon: 'jixiaokaohe',
          iconActive: 'achievements-active'
        },
        {
          title: '定制报表',
          to: {
            name: 'Custom'
          },
          icon: 'dingzhibaobiao',
          iconActive: 'reportForm-active'
        },
        {
          title: '关于我',
          to: {
            name: 'About'
          },
          icon: 'wode',
          iconActive: 'aboutMy-active'
        }
      ]
    }
  },
  components: {
    TabBar
  },
  created() {
    this.active = this.tabbars.findIndex(item => item.to.name === this.$route.name)
  },
  methods: {
    handleChange(v) { }
  }
}
</script>

<style lang="scss" scoped>
.app-container {
  height: 100vh;
  padding-bottom: 50px;
  padding-bottom: calc(50px + constant(safe-area-inset-bottom));
  padding-bottom: calc(50px + env(safe-area-inset-bottom));
  box-sizing: border-box;
  .layout-content {
    height: 100%;
  }
}
</style>
